package com.micro.center.controller;

import com.micro.center.entity.SysUserEntity;
import com.micro.center.service.SysUserService;
import com.micro.common.aop.PermissionRole;
import com.micro.common.constant.Constant;
import com.micro.common.constant.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author pan.shun
 * @since 2022/7/10 01:00
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private SysUserService sysUserService;

    @GetMapping("/list")
    public R getUserList(HttpServletRequest request) {
        return sysUserService.getUserList(request);
    }

    @PermissionRole(role = Constant.ROLE.ADMIN)
    @PostMapping("/update")
    public R updateUser(@RequestBody SysUserEntity sysUserEntity) {
        return sysUserService.updateUser(sysUserEntity);
    }

    @PermissionRole(role = Constant.ROLE.ADMIN)
    @GetMapping("/removeUser/{userId}")
    public R removeUser(@PathVariable String userId) {
        return sysUserService.removeUser(userId);
    }
}
